// 封装获取频道列表的逻辑
import { getChannelAPI } from '@/apis/article'
import { useEffect, useState } from 'react'

const useChannel = () => {
  // 获取频道列表
  const [channelList, setChannelList] = useState([])
  // 调用接口
  useEffect(() => {
      const fetchChannels = async () => {
      const res = await getChannelAPI()
      setChannelList(res.data.channels)
    }
    fetchChannels()
  }, [])
  return {
    channelList
  }
}

export { useChannel }